//
//  WithdrawBtnCell.swift
//  d11
//
//  Created by peale on 2018/11/15.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit
typealias WithdrawSubmitBlock = () -> Void
class WithdrawBtnCell: UITableViewCell {
    var submitBtn : UIButton?
    var withdrawSubmitBlock: WithdrawSubmitBlock?
    func callClickBlock(_ block: @escaping WithdrawSubmitBlock) {
        
        withdrawSubmitBlock = block
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func setUpUI() -> Void {
        self.backgroundColor  = UIColor.clear
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        
        self.submitBtn  = UIButton.init(type: .custom)
        self.submitBtn?.setTitle("提交", for: .normal)
        let layerGradient = CAGradientLayer()
        layerGradient.colors = [
            UIColor.init(red: 1, green: 0.78, blue: 0.45, alpha: 1).cgColor,
            UIColor.init(red: 0.99, green: 0.57, blue: 0.33, alpha: 1).cgColor
        ]
        layerGradient.frame = CGRect(x: 0, y: 0, width: kScreenWidth-20, height: 50)
        self.submitBtn?.layer.addSublayer(layerGradient)
        self.submitBtn?.layer.cornerRadius = 5;
        self.submitBtn?.layer.masksToBounds = true
        self.submitBtn?.addTarget(self, action: #selector(self.actionToWithdrawSubmit), for: .touchUpInside)
        self.contentView.addSubview(self.submitBtn!)
        self.submitBtn?.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-20)
            make.height.equalTo(50)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview()
        }
    }
    @objc func actionToWithdrawSubmit() -> Void {
        if self.withdrawSubmitBlock != nil {
            self.withdrawSubmitBlock!()
        }
    }

}
